package com.xianggu.demo.pattern.strategy;

import java.io.IOException;
import java.util.List;

class FileReaderContext {
    private List<FileReaderStrategy> strategies;

    public FileReaderContext(List<FileReaderStrategy> strategies) {
        this.strategies = strategies;
    }

    public String readFile() throws IOException {
        for (FileReaderStrategy strategy : strategies) {
            String result = strategy.readFile();
            if (result!= null) {
                return result;
            }
        }
        return null;
    }
}